package com.nsl.my_youlai.bbu2.model.bo;

import com.nsl.my_youlai.bbu2.enums.ApparatusRoomCategoryEnum;
import com.nsl.my_youlai.bbu2.enums.ApparatusRoomOwnershipEnum;
import com.nsl.my_youlai.bbu2.enums.CityEnum;
import com.nsl.my_youlai.bbu2.model.bo.bbu.Bbu2;
import lombok.Data;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Data
public class ApparatusRoomBo {

    private Long id;

    private CityEnum city;

    private String county ;
    private ApparatusRoomOwnershipEnum ownership ;

    private ApparatusRoomCategoryEnum roomCategory ;

    private boolean isAnchorRoom ;

    private String location ;

    private double longitude;

    private double latitude;

    //临时使用：计算以某个room为中心时，两room之间的距离
    private double tempDistance;

    private int baseSizePerBbu=4;
    
    private List<Bbu2> bbuList =new ArrayList<>();
//    private List<Bbu5900> bbu5900List=new ArrayList<>();

    public void addBbu(Bbu2 bbu){
        bbuList.add(bbu);
    }

    //按照 能拆分出来的资源排序，资源量大的排前面
//    public void orderOfProvide(){
//        Collections.sort(bbuList,(bbu1, bbu2)->bbu2.getIntIndex()-bbu1.getIntIndex());
//    }
//
//    public void orderOfNeed(){
//        Collections.sort(bbuList,(bbu1, bbu2)->bbu1.getIntIndex()-bbu2.getIntIndex());
//    }

    public Integer getTotalBaseBoardCounter(){
        int sum=0;
        for (Bbu2 bbu : bbuList) {
            sum+=bbu.getBaseBoardCounter();
        }
        return sum;
    }

    public int getBbuMaxSize(){
        if(roomCategory==ApparatusRoomCategoryEnum.CORE_MACHINE_ROOM){
            return 80;
        }
        if(roomCategory==ApparatusRoomCategoryEnum.AGGREGATION_MACHINE_ROOM){
            return 35;
        }
        if(roomCategory==ApparatusRoomCategoryEnum.ACCESS_MACHINE_ROOM){
            return 8;
        }
        if(roomCategory==ApparatusRoomCategoryEnum.COMMUNICATION_STATION_MACHINE_ROOM){
            return 8;
        }
        throw new RuntimeException("机房类型错误");
    }

//    private Integer maxBbuCounter=5;
}
